package com.xauto.pioneer.appuser.adapter;

import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.xauto.pioneer.appuser.MyApplication;
import com.xauto.pioneer.appuser.R;
import com.xauto.pioneer.appuser.model.Payment;

/**
 * Created by Lemon on 2015/12/11.
 * Desc:支付方式 适配器
 */
public class PaymentAdapter extends AbsAdapter<Payment> {

    public PaymentAdapter(Activity context, int layout) {
        super(context, layout);
    }

    @Override
    public ViewHolder<Payment> getHolder() {
        return new TemplateViewHolder();
    }


    private class TemplateViewHolder implements ViewHolder<Payment> {

        private ImageView ivPaymentIcon;
        private TextView tvPaymentName;
        private TextView tvPaymentDescription;
        private ImageView ivPaymentChoose;

        @Override
        public void initViews(View v, int position) {
            ivPaymentIcon = (ImageView) v.findViewById(R.id.ivPaymentIcon);
            ivPaymentChoose = (ImageView) v.findViewById(R.id.ivPaymentChoose);
            tvPaymentName = (TextView) v.findViewById(R.id.tvPaymentName);
            tvPaymentDescription = (TextView) v.findViewById(R.id.tvPaymentDescription);
        }

        @Override
        public void updateData(Payment payment, int position) {
            tvPaymentName.setText(payment.getPayment_name());
            tvPaymentDescription.setText(payment.getPayment_description());
            MyApplication.getDefaultFinalBitmap(context).display(ivPaymentIcon, payment.payment_image_thumb);

            ivPaymentChoose.setImageResource(payment.isChoose ? R.mipmap.ic_common_checked : R.mipmap.ic_common_check);
        }

        @Override
        public void doOthers(Payment payment, int position) {

        }
    }
}
